import request from '@/utils/request'

// 查询协议字段列表
export function listProtocolField(query) {
  return request({
    url: '/rms/protocol/field/',
    method: 'get',
    params: query
  })
}

// 查询协议字段详细
export function getProtocolField(id) {
  return request({
    url: `/rms/protocol/field/${id}/`,
    method: 'get'
  })
}

// 查询协议字段详细历史
export function getHistory(id) {
  return request({
    url: `/rms/protocol/field/${id}/history/`,
    method: 'get',
  })
}

// 新增协议字段
export function addProtocolField(data) {
  return request({
    url: '/rms/protocol/field/',
    method: 'post',
    data: data
  })
}

// 修改协议字段
export function updateProtocolField(data) {
  return request({
    url: `/rms/protocol/field/${data.id}/`,
    method: 'put',
    data: data
  })
}

// 删除协议字段
export function delProtocolField(id) {
  return request({
    url: `/rms/protocol/field/${id}/`,
    method: 'delete'
  })
}

// 查询字段下拉树结构
export function treeselect(query) {
  return request({
    url: `/rms/protocol/field/treeselect`,
    method: 'get',
    params: query
  })
}